import { request } from '@/utils/request'
import type { AddUserDTO, QueryUserDTO, UpdateUserDTO, UserDTO } from '@/types/user'
import type { PageDTO, PageRes, SortDTO } from '@/types/global'

/**
 * 分页查询用户信息
 * @param params
 */
export function queryUserList(params: PageDTO & SortDTO & QueryUserDTO) {
  return request.get<PageRes<UserDTO>>('/api/user', { params })
}

export function getUserById(id: number) {
  return request.get<UserDTO>('/api/user/' + id.toString())
}

export function addUser(data: AddUserDTO) {
  return request.post('/api/user', data)
}

export function updateUser(data: UpdateUserDTO) {
  return request.put('/api/user', data)
}

export function deleteByIds(idList: any) {
  return request.delete('/api/user', {
    params: {
      idList: idList
    }
  })
}
